<template>
	<!-- 热歌模块详细页 -->
	<view class="list">
		<!-- 背景图区域 -->
		<view class="fixbg" :style="{backgroundImage:'url('+imgURL+')'}"></view>
		<!-- 导航栏区域 -->
		<musichead title="歌单" :icon="true" color="#fff"></musichead>
		<!-- 主体区域 -->
		<view class="container" v-show="!islogin">
			<!-- scroll区域 -->
			<scroll-view scroll-y="true">
				<!-- 头部 -->
				<view class="list-head">
					<!-- 图片 -->
					<view class="list-head-img">
						<!-- 获取图片url -->
						<image :src="imgURL"></image>
						<!-- 播放量 -->
						<text class="iconfont">&#xe629;{{playlist.playCount}}</text>
					</view>
					<!-- 榜单名称 -->
					<view class="list-head-text">
						榜单名称
						<text class="list-head-text-font">{{playlist.name}}</text>
						<!-- 网易云音乐 -->
						<view class="list-head-text-img">
							<image src='../../static/logo.png'></image>
							<text>程云风音乐</text>
						</view>
						<!-- 介绍 -->
						<text class="font">{{playlist.description}}</text>
					</view>
				</view>
				<!-- 判断是否是微信小程序 是则显示分享到微信 -->
				<!-- #ifdef MP-WEIXIN -->
				<button open-type="share" class="list-share">
					<text class="iconfont ">&#xe601;</text>分享到微信
				</button>
				<!-- #endif -->
				<!-- 获取歌曲列表 -->
				<view class="list-music">
					<view class="list-music-head">
						<!-- 歌曲列表的icon -->
						<text class="iconfont">&#xe624;</text>
						<text>播放全部</text>
						<text>(共100首)</text>
					</view>
					<!-- 获取详细页列表的歌曲 -->
					<view class="list-music-item" v-for="(item , index) in musicDataList" :key='item.id' @tap="handelToDetail(item.id)">
						<view class="list-music-item-left">
							<!-- 序号 -->
							<text class="index">{{index+1}}</text>
							<!-- 歌曲列表的名称 -->
							<view class="list-music-item-left-img">
								<view>{{item.name}}</view>
								<view>
									<!-- 判断是否是SQ -->
									<image v-if='privileges[index].flag>60' src="../../static/sq.png" ></image>
									<view class="name">{{item.name}}-{{item.ar[0].name}}</view>
								</view>
							</view>
						</view>
						<view class="list-music-item-right">
							<!-- 播放icon -->
							<text class="iconfont">&#xea6e;</text>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	// 引入导航栏
	import musichead from '../../components/musichead/musichead'
	export default {
		// 注册导航栏
		components: {
			musichead
		},
		data() {
			return {
				// 歌曲数据列表
				musicDataList:[],
				// 图片的url地址
				imgURL:'',
				// 榜单介绍数据
				playlist:[],
				// 判断是否是SQ
				privileges:[],
				islogin:true
			}
		},
		methods: {
			// 将获取到的歌曲id给播放页
			handelToDetail (id) {
				
				uni.navigateTo({
					url:'../detail/detail?id='+id
				})
			}
		},
		// 获取榜单的所有数据
		async onLoad(options) {
			uni.showLoading({
				title:'加载中...'
			})
			this.islogin = true
		  const {data:res} = await this.$http({
				url:'/playlist/detail?id='+options.listId
			})
			// 歌曲数据列表
			this.musicDataList = res.playlist.tracks
			console.log(res.playlist.tracks);
			this.$store.commit('INIT_TOPLISTIDS',this.musicDataList)
			// 图片的url地址
			this.imgURL = res.playlist.coverImgUrl
			// 榜单介绍数据
			this.playlist = res.playlist
			// 判断是否是SQ
			this.privileges = res.privileges
			this.islogin = false
			uni.hideLoading()
		}
	}
</script>

<style scoped lang="less">
	.container {
		.list-head {
			display: flex;
			color: #f7f9f6;
			margin: 68rpx 8px 50rpx 8px;

			.list-head-img {
				width: 265rpx;
				height: 265rpx;
				position: relative;

				image {
					position: absolute;
					width: 100%;
					height: 100%;
					border-radius: 15rpx;
				}

				text {
					font-size: 26rpx;
					position: absolute;
					right: 10rpx;
				}
			}

			.list-head-text {
				flex: 1;
				margin-left: 20rpx;
				display: flex;
				flex-flow: column;
				padding-bottom: 20rpx;
				justify-content: space-between;

				.font {
					color: #b7cfe9;
					line-height: 40rpx;
					font-size: 28rpx;
					white-space: normal;
				}

				.list-head-text-font {
					font-size: 50rpx;
				}

				.list-head-text-img {
					display: flex;
					align-items: center;

					image {
						width: 50rpx;
						height: 50rpx;
						border-radius: 50%;
						margin-right: 20rpx;
					}

					text {
						color: #a2b9e0;
					}
				}
			}
		}
		.list-share {
			width: 330rpx;
			height: 70rpx;
			background-color: rgba(0,0,0,.5);
			color: #fff;
			line-height: 70rpx;
			border-radius: 30rpx;
			font-size: 32rpx;
			text {
				margin-right: 10rpx;
			}
		}
		.list-music {
			width: 100%;
			background-color: #fff;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
			overflow: hidden;
			.list-music-head {
				margin: 34rpx 28rpx;
				width: 100%;
				height: 70rpx;
				line-height: 70rpx;
				display: flex;
				.iconfont {
					margin-right: 10rpx;
				}
				text:nth-child(3) {
					font-size: 30rpx;
					margin-left: 10rpx;
					color: #aaa;
				}
				
			}
			.list-music-item {
				margin: 70rpx 28rpx;
				width: 100%;
				height: 80rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.list-music-item-left{
					display: flex;
					align-items: center;
					text {
						margin-right: 52rpx;
						margin-bottom: 15rpx;
					}
					.list-music-item-left-img {
						image {
							width: 26rpx;
							height: 16rpx;
							margin-right: 15rpx;
							vertical-align: middle;
						}
						view:nth-child(2) {
							color: #aaa;
							font-size: 28rpx;
							display: flex;
							align-items: center;
						}
					}
				}
				.list-music-item-right{
					padding-right: 80rpx;
					.iconfont {
						font-size: 36rpx;
					}
				}
			}
		}
		
	}
	.index {
		color: #878787;
	}
	.name {
		display: inline-block;
		width: 50vw;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}
</style>
